//
//  TUserInfoViewController.m
//  LoveShare
//
//  Created by ways on 2017/4/14.
//  Copyright © 2017年 tikeyc. All rights reserved.
//

#import "TUserInfoViewController.h"

#import "TUserInfoTableViewCell.h"

@interface TUserInfoViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,copy)NSArray *cellListTitles;

@property (strong, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation TUserInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.title = @"我的资料";
    
    
    [self initProperty];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [self.navigationController setNavigationBarHidden:NO animated:NO];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/



#pragma mark - init

- (void)initProperty {
    _cellListTitles = @[@[@"头像:"],@[@"小区:",@"房号:"],@[@"昵称:",@"性别:"],@[@"座驾:",@"驾龄:",@"车型:"]];
}


#pragma mark - UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return _cellListTitles.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return [_cellListTitles[section] count];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        return 100;
    }else if (indexPath.section == 3 && indexPath.row == 0) {
        return 200;
    }
    return 44;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    TUserInfoTableViewCell *cell;
    if (indexPath.section == 0) {
        static NSString *indentfier = @"userHomeCellIconImage";
        cell = [tableView dequeueReusableCellWithIdentifier:indentfier];
        if (cell == nil) {
            cell = (TUserInfoTableViewCell *)[[[NSBundle mainBundle] loadNibNamed:@"TUserInfoIconImgCell" owner:nil options:NULL] lastObject];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.isUserInfoIconImgCell = YES;
        }
        
    } else if (indexPath.section == 3 && indexPath.row == 0) {
        static NSString *indentfier = @"userHomeCellCarImage";
        cell = [tableView dequeueReusableCellWithIdentifier:indentfier];
        if (cell == nil) {
            cell = (TUserInfoTableViewCell *)[[[NSBundle mainBundle] loadNibNamed:@"TUserInfoCarImgCell" owner:nil options:NULL] lastObject];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.isUserInfoIconImgCell = NO;
        }
        
    } else {
        static NSString *indentfier = @"userHomeCellText";
        cell = [tableView dequeueReusableCellWithIdentifier:indentfier];
        if (cell == nil) {
            cell = (TUserInfoTableViewCell *)[[[NSBundle mainBundle] loadNibNamed:@"TUserInfoTextCell" owner:nil options:NULL] lastObject];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.myTableView = tableView;
        }
    }

    cell.titleLabel.text = _cellListTitles[indexPath.section][indexPath.row];

    return cell;
}

#pragma mark - UITableViewDelegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}


#pragma mark - UIScrollViewDelegate

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    [self.view endEditing:YES];
    self.tableView.top = 0;
}

@end




